package com.sqx.modules.fiction.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.fiction.entity.NFictionChapter;
import com.sqx.modules.fiction.entity.dto.AddChapterDto;
import com.sqx.modules.fiction.service.FictionChapterService;
import com.sqx.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "小说章节")
@RequestMapping(value = "/system/chapter")
public class FictionChapterController  extends AbstractController {
    @Autowired
    private FictionChapterService fictionChapterService;

    /**
     * 新增小说章节
     * @param addChapterDto
     * @return
     */
    @PostMapping("/addChapter")
    public Result addChapter(@RequestBody AddChapterDto addChapterDto){
        return fictionChapterService.addChapter(addChapterDto);
    }

    /**
     * 修改小说章节
     * @param fictionChapter
     * @return
     */
    @PostMapping("/updateChapter")
    public Result updateChapter(@RequestBody NFictionChapter fictionChapter){
        return fictionChapterService.updateChapter(fictionChapter);
    }

    /**
     * 删除小说章节
     * @param id
     * @return
     */
    @PostMapping("/deleteChapter")
    public Result deleteChapter(@PathVariable Long id){
        return fictionChapterService.deleteChapter(id);
    }


    /**
     * 根据id查询小说章节
     * @param id
     * @return
     */
    @GetMapping("/getChapterById/{id}")
    public Result getChapterById(@PathVariable Long id){
        return fictionChapterService.getChapterById(id);
    }


    /**
     * 根据小说id查询小说章节
     * @param fictionId
     * @return
     */
    @GetMapping("/getChapterByFictionId/{fictionId}")
    public Result getChapterByFictionId(@PathVariable Long fictionId,Integer page,Integer limit){
        return fictionChapterService.getChapterByFictionId(fictionId,page,limit);
    }
}
